package com.itjiange;

/**
 * 普通访问者
 *
 * @author ItJianGe
 * @data 2024/8/27 10:06
 */
public class CommonVisitor implements Visitor {

    private int priceTotal;

    @Override
    public void visitorCpu(Cpu cpu) {
        priceTotal += cpu.price();
        System.out.println("【普通访问者】CPU 价格：" + cpu.price() + " 描述：" + cpu.desc());
    }

    @Override
    public void visitorMemory(Memory memory) {
        priceTotal += memory.price();
        System.out.println("【普通访问者】内存 价格：" + memory.price() + " 描述：" + memory.desc());
    }

    @Override
    public int price() {
        return priceTotal;
    }

    @Override
    public String visitorName() {
        return "普通访问者";
    }
}
